package edu.hitsz.supply;

import edu.hitsz.aircraft.HeroAircraft;

public class BloodSupply extends AbstractSupply {
    private int heal = 30; // 恢复血量

    public BloodSupply(int locationX, int locationY, int speedX, int speedY) {
        super(locationX, locationY, speedX, speedY);
    }

    // 正确实现抽象方法
    @Override
    public void effect(HeroAircraft hero) {
        // 恢复血量不超过最大值
        int newHp = hero.getHp() + heal;
        if (newHp > hero.getMaxHp()) {
            newHp = hero.getMaxHp();
        }
        hero.setHp(newHp);
        vanish();
    }
}